﻿using AutojsController.Config;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutojsController.Services
{
    public class SystemConfigService:IDBService
    {
        public SystemConfigService(IDbContextFactory<DBContext> dbContextFactory) : base(dbContextFactory)
        {
        }

        public async Task<List<SystemConfig>> GetSystemConfigsAsync()
        {
            using var db = dbFactory.CreateDbContext();
            return await db.systemConfig.ToListAsync();
        }
        public async Task<string?> GetSystemConfigAsync(string key)
        {
            using var db = dbFactory.CreateDbContext();
            var config = await db.systemConfig.FindAsync(key);
            return config?.ConfigValue;
        }
    }
}
